package com.itheima.radix;

public class Demo2Radix {
    public static void main(String[] args) {

        System.out.println(6 | 3); // 7
        System.out.println(6 & 3); // 2
        System.out.println(6 ^ 3); // 5
        System.out.println(~3); // -4
        System.out.println("-------------");
        System.out.println(4 << 2); // 16
        System.out.println(4 >> 2); // 1
        System.out.println(75 >>> 1); // 37

        //不允许使用第三方变量实现数据的交换
        int a = 10;
        int b = 20;
        //此处用到的思想就是:一个数被另外一个数异或两次,该数本身不变
        a = a ^ b; // a = 10 ^ 20
        b = a ^ b; // b = 10 ^ 20 ^ 20 --> b = 10
        a = a ^ b; // a = 10 ^ 20 ^ 10 --> a = 20
        System.out.println("a = " + a); // 20
        System.out.println("b = " + b); // 10
    }
}
